package com.qianli.cashmama.trade.client.trade;

import com.fqgj.common.api.Response;
import com.qianli.cashmama.trade.client.trade.request.*;
import com.qianli.cashmama.trade.client.trade.response.CreatePaySuccessTradeResponse;
import com.qianli.cashmama.trade.client.trade.response.CreateServiceResponse;
import com.qianli.cashmama.trade.client.trade.response.CreateTradeResponse;
import com.qianli.cashmama.trade.client.trade.response.ServiceFeePayResponse;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/7/20
 * Time: 上午9:02
 * 交易基础服务门面
 */
public interface TradeApplicationService {

    /**
     * 创建交易
     * 1 对于创建交易 与调用风控是否需要二阶段 待讨论
     * 交易一期 enable交易不存在库存 额度服务。。。可以直接enable 让交易到创建成功状态
     * 调用风控需要二阶段   让二阶段推动交易到待支付回执  本期是否考虑全部放到一个事物
     *
     * @param createTradeRequest
     * @author scrack 写于7月21日
     */
    Response<CreateTradeResponse> createTrade(CreateTradeRequest createTradeRequest);

    /**
     * 创建审核通过的三方订单<用于飞象等open_api推单使用>
     * @param request
     * @return
     */
    Response<CreateTradeResponse> createAuditSuccessTrade(CreateAuditSuccessTradeRequest request);

    /**
     * 创建打款成功订单
     * @param request
     * @return
     */
    @Deprecated
    Response<CreatePaySuccessTradeResponse> createPaySuccessTrade(CreatePaySuccessTradeRequest request);

    /**
     * 信审回调
     *
     * @param auditResultRequest
     * @return
     */
    Response auditCallbackV2(AuditResultRequest auditResultRequest);

    /**
     * 支付回调
     *
     * @param payResultRequest
     */
    Response payCallBack(PayResultRequest payResultRequest);

    /**
     * 支付回调
     *
     * @param payResultRequest
     * @return
     */
    Response payCallBackV2(PayResultRequest payResultRequest);

    /**
     * 支付回调<>open_api使用</>
     * @param payResultRequest
     * @return
     */
    @Deprecated
    Response payCallBackForOpenApi(PayResultRequest payResultRequest);

    /**
     * 前置服务费支付回调
     * 只有支付成功才会回调
     *
     * @param serviceFeePayResultRequest
     */
    @Deprecated
    Response<ServiceFeePayResponse> serviceFeePayCallBack(ServiceFeePayResultRequest serviceFeePayResultRequest);

    /**
     * 关闭交易
     *
     * @param closeTradeRequest
     * @return
     */
    Response closeTrade(CloseTradeRequest closeTradeRequest);


    /**
     * 重新发起支付（重绑卡）
     *
     * @param repayTradeRequest
     * @return
     */
    Response updateBankInfoAndLoan(RepayTradeRequest repayTradeRequest);

    /**
     * 贷超重绑卡
     * @param repayTradeRequest
     * @return
     */
    Response updateBankInfoAndLoanMarket(RepayTradeRequest repayTradeRequest);

    /**
     * 签名回执
     *
     * @param signCallbackRequest
     * @return
     */
    Response signCallback(SignCallbackRequest signCallbackRequest);

    /**
     * 更新合同存储信息
     *
     * @param updateContractRequest
     * @return
     */
    Response updateContract(UpdateContractRequest updateContractRequest);

    /**
     * 关闭交易(在签名成功之后，校验digio返回的name时错误)
     *
     * @return
     */
    Response closeTradeAfterCheckSignName(String tradeNo);

    /**
     * 完成highmark
     *
     * @param tradeNo
     * @return
     */
    Response completeHighMark(String tradeNo);

    /**
     * 完成highmark
     *
     * @param tradeNo
     * @return
     */
    Response completeHighMarkV2(String tradeNo);

    /**
     * 提现确认
     *
     * @param withdrawCallbackRequest
     * @return
     */
    Response withdrawCallback(WithdrawCallbackRequest withdrawCallbackRequest);

    /**
     * 更新trade渠道号
     * @param tradeNo
     * @param channelCode
     * @return
     */
    Response<Boolean> updateTradeChannelCodeByTradeNo(String tradeNo, String channelCode);

    /**
     * 创建服务费支付请求
     * @param request
     * @return
     */
    Response<CreateServiceResponse> createServiceFeePayment(CreateServiceFeeRequest request);

    /**
     * 服务费支付成功回调
     * @return
     */
    Response<Boolean> serviceFeePaymentCallBack(ServiceFeePaymentCallBackRequest request);


    Response<Boolean> copyOldUnpaidOrders(String mobile,String userCode, String extraInfo);



}
